/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DrawingPanel.java
 *
 * Created on 09-sep-2011, 20:51:16
 */

package br.usp.ime.faguilar.guis.MathExpressionDrawing.Panels;
 
import MathExpression.Graphics.Drawable;
import java.awt.Graphics;

/**
 *
 * @author frank
 */
public class DrawingPanel extends javax.swing.JPanel {

    protected Drawable drawable;
    /** Creates new form DrawingPanel */
    public DrawingPanel() {
        initComponents();
        initializeAllMyFields();
    }

    protected void initializeAllMyFields() {
        this.setDrawable(null);
    }

    public Drawable getDrawable() {
        return drawable;
    }

    public void setDrawable(Drawable drawable) {
        this.drawable = drawable;
    }

    @Override
    public void paintComponent(Graphics g){
        super.paintComponent(g);
        draw(g);
    }

    protected void draw(Graphics g){
        drawable.draw(g);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(0, 300, Short.MAX_VALUE)
        );
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    // End of variables declaration//GEN-END:variables

}
